/**
 * Created by kangm_000 on 2016/11/30 0030.
 */
var vm = new Vue({
        el: '#main',
        data: {
            menus: [
                {id: '10', name: "首页", pid: "1", url: "index.html"},
                {id: '20', name: "表格", pid: "1", url: "tables.html"},
                {id: '30', name: "日历", pid: "1", url: "calendar.html"},
                {id: '40', name: "表单", pid: "1", url: "form.html"},
                {id: '50', name: "图表", pid: "1", url: "chart.html"},
                {id: '60', name: "数据列表", pid: "1", url: ""},
                {id: '601', name: "文字列表", pid: "60", url: "table-list.html"},
                {id: '602', name: "图文列表", pid: "60", url: "table-list-img.html"},
                {id: '70', name: "树形组件", pid: "1", url: "tree.html"},
                {id: '70', name: "404", pid: "1", url: "404.html"}
            ],
            currentPage: {}
        },//改变分数的函数
        created: function () {
            $("#mainFrame").attr("src", "index.html");
        },
        computed: {
            filterRootMenus: function () {
                var self = this;
                return self.menus.filter(function (menu) {
                    return menu.pid == "1";
                })
            }
        },
        methods: {
            childMenus: function (menus, pid) {
                return menus.filter(function (menu) {
                    return menu.pid == pid;
                })
            },
            menuChange: function (text, url) {
                if (text && text != this.currentPage) {
                    this.currentPage = text;
                    $("#mainFrame").attr("src", url);
                }
            }
        }
    })
    ;

function selectMenu(menu) {
    vm.currentPage = menu;
}

/**
 * 调整iframe高度
 */
function reinitIframe(){
    var iframe = document.getElementById("mainFrame");
    try {
        //改变子页面样式
        var height = iframe.contentWindow.getContentHeight();
        iframe.height = height;
    } catch (ex) {

    }
}
window.setInterval("reinitIframe()", 200);